package cn.tedu.car.backend.vehicle.controller;


import cn.tedu.car.backend.base.response.JsonResult;
import cn.tedu.car.backend.base.response.PageData;
import cn.tedu.car.backend.vehicle.pojo.dto.StationInfoQuery;
import cn.tedu.car.backend.vehicle.pojo.dto.VehicleQuery;
import cn.tedu.car.backend.vehicle.pojo.dto.VehicleSaveParam;
import cn.tedu.car.backend.vehicle.pojo.entity.StationInfo;
import cn.tedu.car.backend.vehicle.pojo.entity.Vehicle;
import cn.tedu.car.backend.vehicle.pojo.vo.StationInfoVO;
import cn.tedu.car.backend.vehicle.pojo.vo.VehicleVO;
import cn.tedu.car.backend.vehicle.service.VehicleService;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.management.Query;
import java.io.File;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/vehicle")
public class VehicleController {
    @Autowired
    VehicleService vehicleService;

    @GetMapping("select")
    public JsonResult selectVehicle(VehicleQuery vehicleQuery) {
        log.debug("查询车辆 VehicleQuery={}",vehicleQuery);
        PageData list=vehicleService.selectVehicle(vehicleQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult saveVehicle(VehicleSaveParam vehicleSaveParam){
        log.debug("新增车辆信息，vehicleSaveParam={}",vehicleSaveParam);
        vehicleService.saveVehicle(vehicleSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult deleteVehicle(@PathVariable Long id){
        log.debug("删除车辆信息，id={}", id);
        vehicleService.deleteVehicle(id);
        return JsonResult.ok();
    }
    @GetMapping("selectStation")
    public JsonResult selectStation(StationInfoQuery stationInfoQuery) {
        log.debug("查询站点 stationInfoQuery={}",stationInfoQuery);
        List<StationInfoVO> list=vehicleService.selectStation(stationInfoQuery);
        return JsonResult.ok(list);
    }
}
